﻿package com.android.publicModule.model.sms;

import android.content.Context;
import android.telephony.TelephonyManager;

/**
 * SIM卡状态及信息获取
 * @author 张少志
 *
 */
public class GetCurrentSimState {

    public GetCurrentSimState() {
    }
    
    public SimState getCurrentSimState(Context context) {
        SimState simState = new SimState();
        TelephonyManager telMgr=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
        if(telMgr.getSimState()==TelephonyManager.SIM_STATE_READY)
        {
            simState.setSimState(true);
        }
        else if(telMgr.getSimState()==TelephonyManager.SIM_STATE_ABSENT)
        {
            simState.setSimState(false);
        }
        else
        {
            simState.setSimState(false);
        }
        simState.setOperator(telMgr.getNetworkOperator());
        simState.setOperatorName(telMgr.getNetworkOperatorName());
        simState.setImsi(telMgr.getSubscriberId());
        return simState;
    }
}
